﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.WebTesting;

namespace Vs2010LoadTestPluginLib
{
    public class BypassStaticFiles : WebTestPlugin
    {
        public override void PostRequest(object sender, PostRequestEventArgs e)
        {
            var removeList = new List<WebTestRequest>();

            foreach (WebTestRequest dependent in e.Request.DependentRequests)
            {
                string url = dependent.Url.ToLowerInvariant();

                if (url.EndsWith(".gif") || url.EndsWith(".jpg") || url.EndsWith(".png"))
                    removeList.Add(dependent);

                //TEST SPECIFIC
                else if( url == "http://img.cdn.betclic.com/page/benl/sports/InternalAds/sponsoring_sponsoring.aspx".ToLowerInvariant() )
                    removeList.Add(dependent);
            }

            foreach (WebTestRequest dependent in removeList)
                e.Request.DependentRequests.Remove(dependent);
        }
    }
}
